package com.yourcompany.api.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yourcompany.api.entity.ChargingOrder;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 充电订单 Mapper 接口
 */
@Mapper
public interface ChargingOrderMapper extends BaseMapper<ChargingOrder> {
    
    /**
     * 查询用户的充电中订单
     */
    @Select("SELECT * FROM charging_order WHERE user_id = #{userId} AND status = 1 AND is_deleted = 0")
    List<ChargingOrder> getChargingOrders(@Param("userId") Long userId);
    
    /**
     * 统计用户的订单数
     */
    @Select("SELECT COUNT(*) FROM charging_order WHERE user_id = #{userId} AND is_deleted = 0")
    int countUserOrders(@Param("userId") Long userId);
} 